package Try;

import Try.FileUtils.FileUtil;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class Main27 {

    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\ruanjie\\Desktop\\cleanCloth.txt");

        List<String> list = FileUtil.readFile(file);

        Collections.shuffle(list);

        List<Integer> indexList = new ArrayList<>();

        for (int i=0;i<1500;i++){
            int index = (int)(Math.random()*(list.size()));
            System.out.println(index);
            while(indexList.contains(index)){
                index = (int)(Math.random()*(list.size()));
            }
            indexList.add(index);
        }

//        List<String> trainCloth = new LinkedList<>();
        List<String> testCloth  = new ArrayList<>();

        for (int i=0;i<indexList.size();i++){
            testCloth.add(list.get(i));
        }

        list.removeAll(testCloth);

        File file1 = new File("C:\\Users\\ruanjie\\Desktop\\trainCloth.txt");
        File file2 = new File("C:\\Users\\ruanjie\\Desktop\\testCloth.txt");

        Collections.sort(list);
        Collections.sort(testCloth);
        FileUtil.writeToFile(file1,list);
        FileUtil.writeToFile(file2,testCloth);
    }



}
